<html>
<head><meta charset="utf-8"><title>Portable pure-Rust implementation · project-portable-simd · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/index.html">project-portable-simd</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html">Portable pure-Rust implementation</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="213479405"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213479405" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213479405">(Oct 15 2020 at 19:56)</a>:</h4>
<p><span class="user-mention silent" data-user-id="125270">scottmcm</span> <a href="#narrow/stream/257879-project-portable-simd/topic/cranelift.20backend/near/213368109">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="116122">simulacrum</span> <a href="#narrow/stream/257879-project-portable-simd/topic/cranelift.20backend/near/213362674">said</a>:</p>
<blockquote>
<p>if it lowers to non-simd, for example, on cranelift that seems fine</p>
</blockquote>
<p>Having non-simd lowering seems generally useful.  I could imagine some targets only using that, for example.</p>
<p>(No idea what the best way to pick it for cranelift would be, though.)</p>
</blockquote>
<p>In general, it seems like portable SIMD <em>needs</em> to have a portable pure-Rust implementation that can compile anywhere, so that that can be used for things like MIRI, or new platforms being ported to, or similar. That also means we can add new intrinsics without writing a version of them for every target, because targets without an implementation will just use the pure-Rust implementation until they have a native one.</p>



<a name="213479643"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213479643" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213479643">(Oct 15 2020 at 19:58)</a>:</h4>
<p>It wouldn't be something that only existed for the cranelift backend. It'd also be used for any Rust target that doesn't have SIMD, or hasn't implemented it yet. And it'd be used for any operation that a target can't or doesn't accelerate.</p>



<a name="213479700"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213479700" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213479700">(Oct 15 2020 at 19:59)</a>:</h4>
<p>Ideally, we'd have a checklist for each target of "here are things for which the target is using the generic version", which would make it easy for people to contribute more optimized versions (along with benchmarks).</p>



<a name="213479725"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213479725" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213479725">(Oct 15 2020 at 19:59)</a>:</h4>
<p>That'd make it much more incremental work.</p>



<a name="213479891"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213479891" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213479891">(Oct 15 2020 at 20:00)</a>:</h4>
<p>Adding a new function would still require designing a reasonable interface for it, but it wouldn't require implementing multiple target backends immediately. It'd just require a portable implementation and at least one target-specific implementation.</p>



<a name="213479948"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213479948" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213479948">(Oct 15 2020 at 20:00)</a>:</h4>
<p>The portable implementation would also help for testsuites: tests could assert that the portable and non-portable versions match in behavior (modulo allowable precision variations in some cases).</p>



<a name="213480070"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213480070" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213480070">(Oct 15 2020 at 20:01)</a>:</h4>
<p>Yeah, that seems like a very reasonable way forward :)</p>



<a name="213480088"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213480088" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213480088">(Oct 15 2020 at 20:01)</a>:</h4>
<p>Though maybe not an easy one.</p>



<a name="213480180"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213480180" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213480180">(Oct 15 2020 at 20:02)</a>:</h4>
<p>it sounds a lot tractable than getting new simd_foo apis for any unsupported ops</p>



<a name="213480235"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213480235" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213480235">(Oct 15 2020 at 20:03)</a>:</h4>
<p>The most critical thing would be a reasonable framework/pattern for selecting which implementation to use on each target, without writing piles of <code>cfg</code> goo everywhere.</p>



<a name="213480258"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213480258" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213480258">(Oct 15 2020 at 20:03)</a>:</h4>
<p>Ideally in a way that allows easily extracting the "which implementation" information for target documentation tables.</p>



<a name="213480298"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213480298" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213480298">(Oct 15 2020 at 20:03)</a>:</h4>
<p>(And in a way that allows tests to also pull in the portable implementations, without compiling the portable implementations into std/core.)</p>



<a name="213484698"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213484698" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213484698">(Oct 15 2020 at 20:41)</a>:</h4>
<p>I'd like to be able to have, like, a #[scalar] and a #[vectorized] version? Just throwing-at-wall level of musing on what that would look like.</p>



<a name="213485588"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213485588" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213485588">(Oct 15 2020 at 20:48)</a>:</h4>
<p><span class="user-mention" data-user-id="281757">@Jubilee</span> Can you clarify the distinction there?</p>



<a name="213485889"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213485889" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213485889">(Oct 15 2020 at 20:51)</a>:</h4>
<p>Oh, like... I'm sort of presuming a scalar fallback in my head that essentially just reduces "SIMD" to "a bunch of Rusty arrays", and then that is the initial presentation for anything, and then on certain platforms we have #[vectorized] optimizations so we select #[vectorized] for them.</p>



<a name="213485993"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213485993" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213485993">(Oct 15 2020 at 20:52)</a>:</h4>
<p>and #[vectorized] attempts to use a true SIMD codegen path, or rather is expressing it will.</p>



<a name="213486101"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213486101" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213486101">(Oct 15 2020 at 20:52)</a>:</h4>
<p>"cfg goo but nice and tidy"</p>



<a name="213486143"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213486143" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213486143">(Oct 15 2020 at 20:53)</a>:</h4>
<p>It might be more subtle than that if we're to allow:</p>
<p><span class="user-mention silent" data-user-id="239881">Josh Triplett</span> <a href="#narrow/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation/near/213479891">said</a>:</p>
<blockquote>
<p>Adding a new function would still require designing a reasonable interface for it, but it wouldn't require implementing multiple target backends immediately. It'd just require a portable implementation and at least one target-specific implementation.</p>
</blockquote>
<p>(which i think is desirable)</p>



<a name="213486401"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213486401" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213486401">(Oct 15 2020 at 20:55)</a>:</h4>
<p>I guess what I'm trying to do is nail down in my head what "portable pure Rust" really means in a world where codegen lowers to LLVM instructions or sometimes not, it's not like we actually _have_ a Rust machine. :^)</p>



<a name="213486509"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213486509" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213486509">(Oct 15 2020 at 20:55)</a>:</h4>
<p>I mean if you give me an FPGA and cover my bills for a few months I'd be happy to try but... :^)</p>



<a name="213487322"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213487322" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213487322">(Oct 15 2020 at 21:01)</a>:</h4>
<p>By "portable pure Rust", I mean "target-independent". If the platform can autovectorize, that's great, but if it can't, the same code should still work.</p>



<a name="213487673"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213487673" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213487673">(Oct 15 2020 at 21:04)</a>:</h4>
<p>Technically that is what already exists... because we were not considering "LLVM" as part of our target triple... quad? quint? whatever. Target spec. Now we do have to, because of the functional differences between LLVM and cranelift. At the moment, any such fallback would be scalar, unless Rust develops the ability to think about vectors directly.</p>



<a name="213487885"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213487885" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213487885">(Oct 15 2020 at 21:06)</a>:</h4>
<p>My understanding is that we'd manually implement the operations, e.g. instead of calling simd_add, we'd construct a new vector with the fields of the elementwise addition of each field in turn</p>



<a name="213488240"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213488240" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213488240">(Oct 15 2020 at 21:09)</a>:</h4>
<p>Right.</p>



<a name="213488633"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213488633" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213488633">(Oct 15 2020 at 21:13)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="n">a</span><span class="p">.</span><span class="n">into_iter</span><span class="p">().</span><span class="n">zip</span><span class="p">(</span><span class="n">b</span><span class="p">.</span><span class="n">into_iter</span><span class="p">()).</span><span class="n">map</span><span class="p">(</span><span class="o">|</span><span class="p">(</span><span class="n">a</span><span class="p">,</span><span class="w"> </span><span class="n">b</span><span class="p">)</span><span class="o">|</span><span class="w"> </span><span class="n">a</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">b</span><span class="p">).</span><span class="n">collect</span>::<span class="o">&lt;</span><span class="n">TxN</span><span class="o">&gt;</span><span class="p">()</span><span class="w"></span>
</code></pre></div>

<p>is simple enough to write, I'm just thinking about the avoiding-cfg-goo part.</p>



<a name="213488765"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213488765" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213488765">(Oct 15 2020 at 21:13)</a>:</h4>
<p>The portable fallbacks could also use things like "safe-transmute to u64s and operate on those", for that matter.</p>



<a name="213488872"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213488872" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213488872">(Oct 15 2020 at 21:14)</a>:</h4>
<p>And yeah, avoiding the cfg goo is the hard part here. Code generation is a possibility, but annoying. Turning the abstraction layer upside down and having targets either implement or <code>pub use</code> things would help, but there'd be a lot of wrappers (especially for traits or methods where we can't just import an implementation with a single <code>pub use</code>).</p>



<a name="213489878"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213489878" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213489878">(Oct 15 2020 at 21:25)</a>:</h4>
<p>So I think we're still going to be describing "default vectorization" (i.e. not, use scalar) vs. "explicit vectorization" at least once, internally, and I think it's best if we just not try at all inside stdsimd to abstract over the fact we're dropping to scalar, so we do use some flavor of cfg at least once and everything does get written twice.</p>



<a name="213490219"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213490219" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213490219">(Oct 15 2020 at 21:28)</a>:</h4>
<p>So that whatever is selecting algorithms from us during compilation has a lookup table and at least one entry per algorithm in its lookup table.</p>



<a name="213490477"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213490477" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213490477">(Oct 15 2020 at 21:31)</a>:</h4>
<p>I'm trying to interpret what you mean by "and everything does get written twice". Do you mean "once portably, and at least once per target platform that wants to optimize"? Or do you mean multiple portable implementations?</p>



<a name="213490501"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213490501" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213490501">(Oct 15 2020 at 21:31)</a>:</h4>
<p>I'm <em>hoping</em> that we have just one portable version, and then a bunch of target-specific versions.</p>



<a name="213490681"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213490681" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213490681">(Oct 15 2020 at 21:33)</a>:</h4>
<p>Once for the scalar fallback, and the required number of times to enable per-target optimizations with whatever additional abstractions we deem necessary.</p>



<a name="213490857"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213490857" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213490857">(Oct 15 2020 at 21:35)</a>:</h4>
<p>Got it. Yeah, that's what I'd expect.</p>



<a name="213490988"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213490988" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213490988">(Oct 15 2020 at 21:35)</a>:</h4>
<p>There's one additional desirable property I'd like if we can get it: targets shouldn't have to list which things they <em>don't</em> have implementations for.</p>



<a name="213491065"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213491065" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213491065">(Oct 15 2020 at 21:36)</a>:</h4>
<p>We should be able to generate that list, and document it in per-target documentation, but we shouldn't have to <em>write</em> and <em>update</em> it.</p>



<a name="213491083"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213491083" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213491083">(Oct 15 2020 at 21:36)</a>:</h4>
<p>Because when we add a new portable operation, we shouldn't have to go to every target and say "no implementation here".</p>



<a name="213491099"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213491099" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213491099">(Oct 15 2020 at 21:36)</a>:</h4>
<p>A patch for a new portable operation shouldn't have to touch targets that don't implement it, at all.</p>



<a name="213491194"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213491194" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213491194">(Oct 15 2020 at 21:37)</a>:</h4>
<p>Adding new <code>simd_*</code> platform intrinsics to cg_llvm is really easy if there is already an LLVM intrinsic for it. cg_clif also has a few functions to easily implement new per lane <code>simd_*</code> platform intrinsics using scalar operations only.</p>



<a name="213491607"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213491607" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213491607">(Oct 15 2020 at 21:41)</a>:</h4>
<p>What should happen is that during compilation, a selection function awakens, inspects the available functions it can compile in according to the currently defined spec, sorts them in a predictable order, and then walks away with the last one.</p>



<a name="213491621"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213491621" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213491621">(Oct 15 2020 at 21:41)</a>:</h4>
<p>if there is only one, it's the last one.</p>



<a name="213492569"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213492569" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213492569">(Oct 15 2020 at 21:50)</a>:</h4>
<p>This is why my brain jumped ahead to two distinct annotations for use within stdsimd... one would signal that it should always be moved into std and so always available for selection, and the library should be able to notice if it has 1 item that is <strong>not</strong> the scalar implementation.</p>



<a name="213494512"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213494512" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213494512">(Oct 15 2020 at 22:12)</a>:</h4>
<p>Oh, I see.</p>



<a name="213494541"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213494541" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213494541">(Oct 15 2020 at 22:13)</a>:</h4>
<p><span class="user-mention" data-user-id="281757">@Jubilee</span> Is your intention here that std may need to supply <em>multiple</em> functions, to be selected from at either compile-time or runtime depending on target capabilities and target feature selection?</p>



<a name="213494565"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213494565" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213494565">(Oct 15 2020 at 22:13)</a>:</h4>
<p>(e.g. x86_64 with AVX, x86_64 with only SSE2...)</p>



<a name="213494597"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213494597" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213494597">(Oct 15 2020 at 22:13)</a>:</h4>
<p>And then the portable function may or may not be the "last" of those, depending on if the target features are sufficient to <em>always</em> allow a better one?</p>



<a name="213494899"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213494899" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213494899">(Oct 15 2020 at 22:16)</a>:</h4>
<p>This is what I understand as required to meet the constraints in a sane manner, yes, even if the selector's choice does not actually pull out code from std but instead fires off a codegen path or something.</p>



<a name="213495036"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213495036" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213495036">(Oct 15 2020 at 22:18)</a>:</h4>
<p>and even if the selection process is actually done on a significantly winnowed field from the full set of possible implementations because of some other previously-applied constraint.</p>



<a name="213497233"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213497233" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213497233">(Oct 15 2020 at 22:45)</a>:</h4>
<p>So I just read through this thread and I'm not sure that everyone is on the same page with this.  Just a few thoughts I have:</p>
<ul>
<li>The compiler is aware of which backend is used when lowering, right? (AST to HIR, HIR to MIR, etc, not just codegen)</li>
<li>The compiler is aware of which target-features are enabled during codegen (at least it could be, in practice I think this is mostly deferred to LLVM?)</li>
<li>The compiler can query the backend for support of a particular SIMD intrinsic, if it doesn't exist it can be lowered to pure rust before codegen, if it does exist it can send the intrinsic as is to the backend</li>
</ul>
<p>If we're going 100% platform-intrinsics I don't think there needs to be anything special going on in stdsimd or any other rust crate, no cfg or any other special attributes.  Maybe some of this is obvious or maybe some of it is not a good idea but I'm not sure anyone is even on the same page of where the backend intrinsic/pure rust implementation delegation should be occurring</p>



<a name="213499234"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213499234" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213499234">(Oct 15 2020 at 23:09)</a>:</h4>
<p>To clarify my slowly-forming mental picture of how this looks:</p>
<p>To my mind, the stdsimd calls are currently essentially a façade for calls to LLVM.<br>
What I would suggest is that in stdsimd live &gt;=1 branches:</p>
<ul>
<li>The scalar fallback.</li>
<li>For explicit SIMD ops, 0 or more façades that could denote compiler calls to explicitly vectorize.</li>
</ul>



<a name="213500625"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213500625" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213500625">(Oct 15 2020 at 23:28)</a>:</h4>
<p>The selection function itself would live in rustc, in a codegen-path-agnostic location. It is called once sufficient information has been gathered to make a decision. It makes a choice and it always has at least 1 choice available (the scalar fallback). By doing so there, it can handle whether or not it calls something. By having at least an initial facade live in std::simd, we don't have to go exploring the bowels of rustc just to try to guarantee the two implementations are correctly aligned.</p>
<p>After that, if it is appropriate for more information to live in stdsimd, we can put it there.<br>
If it is appropriate for more information to live inside the codegen crates, we can put it there.</p>
<p>But I am not wild about the thought of putting absolutely <strong>all</strong> information inside the compiler for all things here.<br>
I would go so far as to say that if everything-everything lives in the compiler, at that point we should just build out and stabilize <code>#![feature(platform_intrinsics)]</code> for public usage.</p>



<a name="213501009"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213501009" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213501009">(Oct 15 2020 at 23:33)</a>:</h4>
<p>Is there a reason to provide the scalar fallback in stdsimd instead of having rustc lower simd_add etc appropriately for the backend in use?</p>



<a name="213501186"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213501186" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213501186">(Oct 15 2020 at 23:36)</a>:</h4>
<p>We make the workings of the library more opaque and we weaken the ability to describe more specialized versions for a given arch.</p>



<a name="213501188"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213501188" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213501188">(Oct 15 2020 at 23:36)</a>:</h4>
<p>There's still a difference between our API and the platform-intrinsics API, notably at least some of the ops are inherently unsafe</p>



<a name="213501218"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213501218" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213501218">(Oct 15 2020 at 23:37)</a>:</h4>
<p>What do you mean by more specialized versions for a given arch?</p>



<a name="213501326"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213501326" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213501326">(Oct 15 2020 at 23:38)</a>:</h4>
<p>If we wish to write an implementation of a given function that uses certain intrinsic functions for an architecture.</p>



<a name="213502448"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213502448" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213502448">(Oct 15 2020 at 23:56)</a>:</h4>
<p>Since there's no way to interact with target-feature I feel like that's unlikely. But I do see your point</p>



<a name="213502488"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213502488" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213502488">(Oct 15 2020 at 23:57)</a>:</h4>
<p>We are already talking about compiler commits, so.</p>



<a name="213502587"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213502587" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213502587">(Oct 15 2020 at 23:58)</a>:</h4>
<p>True.  I suppose something that might be somewhat in between what we're both suggesting is something like <code>#[cfg(backend_supports = "simd_add")]</code></p>



<a name="213502613"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213502613" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213502613">(Oct 15 2020 at 23:58)</a>:</h4>
<p>I'm not sure we should be checking which particular backend is in use</p>



<a name="213502630"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213502630" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213502630">(Oct 15 2020 at 23:59)</a>:</h4>
<p>I think stdsimd should just provide information and then the compiler uses that.</p>



<a name="213502744"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213502744" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213502744">(Oct 16 2020 at 00:00)</a>:</h4>
<p>I'm not sure how that would work, for example if you have a function in stdsimd that uses multiple intrinsics, a backend may support some subset but not all of them</p>



<a name="213502767"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213502767" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213502767">(Oct 16 2020 at 00:00)</a>:</h4>
<p>unless we are saying a backend supports all or none</p>



<a name="213502838"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213502838" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213502838">(Oct 16 2020 at 00:01)</a>:</h4>
<p>Mmm, I think we are, aren't we?</p>



<a name="213502902"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213502902" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213502902">(Oct 16 2020 at 00:02)</a>:</h4>
<p>Like... at least within a function, it either has to support everything that went on inside that function, or it has to use fallback.</p>



<a name="213502956"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213502956" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213502956">(Oct 16 2020 at 00:03)</a>:</h4>
<p>Right, but I could imagine for example a microcontroller-specific backend that supports <code>simd_add</code>, <code>simd_sub</code>, etc, but not say transcendental functions</p>



<a name="213503018"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213503018" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213503018">(Oct 16 2020 at 00:04)</a>:</h4>
<p>Continuations, I guess.</p>



<a name="213503019"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213503019" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213503019">(Oct 16 2020 at 00:04)</a>:</h4>
<p>you might just end up copying a lot of scalar fallback code into the backend</p>



<a name="213503901"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213503901" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213503901">(Oct 16 2020 at 00:15)</a>:</h4>
<p>well, here's something else.  LLVM doesn't have a vectorized round-to-int (<code>lround</code>/<code>llround</code>). does this mean all backends are prevented from implementing it because it's all-or-nothing?</p>



<a name="213503982"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213503982" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213503982">(Oct 16 2020 at 00:16)</a>:</h4>
<p>right, thats the reason for wanting the flexibility to implement things in a target specific manner with a scalar fallback</p>



<a name="213503985"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213503985" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213503985">(Oct 16 2020 at 00:16)</a>:</h4>
<p>maybe the answer is "that's fine" but just want to suss out the implications</p>



<a name="213504031"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213504031" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213504031">(Oct 16 2020 at 00:17)</a>:</h4>
<p>Continuations and the query system exist. Multiple attempts to expand the code correctly can be performed and then the scalar fallback can literally be fallen back to.</p>



<a name="213504143"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213504143" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213504143">(Oct 16 2020 at 00:18)</a>:</h4>
<p>Is your intent that depending on the backend, various <code>simd_*</code> functions may or may not be available?</p>



<a name="213504174"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213504174" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213504174">(Oct 16 2020 at 00:19)</a>:</h4>
<p>Given that such seems to be the motivating complaint, yes.</p>



<a name="213504203"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213504203" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213504203">(Oct 16 2020 at 00:19)</a>:</h4>
<p>there's also a lot of stuff without a simd_* equivalent</p>



<a name="213504212"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213504212" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213504212">(Oct 16 2020 at 00:19)</a>:</h4>
<p>that would be nice to support</p>



<a name="213504298"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213504298" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213504298">(Oct 16 2020 at 00:20)</a>:</h4>
<p>Okay, so I think we're on the same page with that, but I think simply using cfg to indicate if the intrinsic is available or not is a lot more "typical" rust.  Just like using <code>target_arch</code> to determine which <code>std::arch</code> intrinsics you have available</p>



<a name="213504338"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213504338" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213504338">(Oct 16 2020 at 00:21)</a>:</h4>
<p>This is a lot lower granularity of course, but I think it's the same idea</p>



<a name="213504351"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213504351" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213504351">(Oct 16 2020 at 00:21)</a>:</h4>
<p>higher granularity?</p>



<a name="213504507"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213504507" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213504507">(Oct 16 2020 at 00:23)</a>:</h4>
<p><span class="user-mention" data-user-id="209168">@Thom Chiovoloni</span> I would hope that pretty much everything "fundamental" would end up with a platform intrinsic</p>



<a name="213504509"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213504509" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213504509">(Oct 16 2020 at 00:23)</a>:</h4>
<p>An attr can expand to other attrs.</p>



<a name="213504694"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213504694" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213504694">(Oct 16 2020 at 00:26)</a>:</h4>
<p><span class="user-mention" data-user-id="312331">@Caleb Zulawski</span> Maybe, but there's an appeal to all it takes to include is for there to be a reasonable interface, a portable implementation, and at least one target specific one. Getting patches into LLVM that are usable in rust is slow and difficult.</p>



<a name="213504723"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213504723" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213504723">(Oct 16 2020 at 00:26)</a>:</h4>
<p>Getting patches in rustc is less slow but still challenging since its a separate repo and requires experience with the compiler.</p>



<a name="213504768"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213504768" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213504768">(Oct 16 2020 at 00:27)</a>:</h4>
<p>I guess my point is that the following is pretty much trivial:</p>
<div class="codehilite"><pre><span></span><code>#[cfg(backend_supports = &quot;simd_neg&quot;)]
fn neg(self) -&gt; Self { unsafe { simd_neg(self) } }

#[cfg(not(backend_supports = &quot;simd_neg&quot;))]
fn neg(self) -&gt; Self { /* scalar code */ }
</code></pre></div>


<p>but replacing those attributes with <code>#[vector]</code> and <code>#[scalar]</code> or whatever involves a fair bit of magic</p>



<a name="213504846"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213504846" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213504846">(Oct 16 2020 at 00:28)</a>:</h4>
<p><span class="user-mention" data-user-id="209168">@Thom Chiovoloni</span> sorry, the terminology isn't great, "platform intrinsics" are rustc's intrinsics, not LLVM's, as in <code>extern "platform-intrinsics" {}</code></p>



<a name="213504857"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213504857" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213504857">(Oct 16 2020 at 00:28)</a>:</h4>
<p>it was just a draft idea with some placeholders.</p>



<a name="213504862"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213504862" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213504862">(Oct 16 2020 at 00:28)</a>:</h4>
<p>thats not particularly the sort of thing i'm talking about. i have no opinion about #[vector] and #[scalar], but think the granularity needs to be a little more fine than that in practice</p>



<a name="213504876"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213504876" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213504876">(Oct 16 2020 at 00:29)</a>:</h4>
<p>i also don't think it would be hard to add #[vector] or #[scalar] tho</p>



<a name="213504894"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213504894" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213504894">(Oct 16 2020 at 00:29)</a>:</h4>
<p>I guess my point is I don't see any reason it _shouldn't_ just be cfg, instead of something more magic, regardless of the syntax of the attribute</p>



<a name="213504901"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213504901" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213504901">(Oct 16 2020 at 00:29)</a>:</h4>
<p>I don't... care about that? I just don't.</p>



<a name="213504974"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213504974" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213504974">(Oct 16 2020 at 00:30)</a>:</h4>
<p>thats just the color of the bikeshed honestly</p>



<a name="213504975"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213504975" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213504975">(Oct 16 2020 at 00:30)</a>:</h4>
<p>I suppose I do though, I'm very much against magic attributes that make the code much less approachable</p>



<a name="213504999"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213504999" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213504999">(Oct 16 2020 at 00:30)</a>:</h4>
<p>cfg seems sufficient to me and broadly understood</p>



<a name="213505008"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213505008" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213505008">(Oct 16 2020 at 00:31)</a>:</h4>
<p>whatever. I just described two different markings meant to be read as distinct and representing a higher-level organization.</p>



<a name="213505013"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213505013" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213505013">(Oct 16 2020 at 00:31)</a>:</h4>
<p>i'm not if they're useful. i don't think this matters or is the place to make this decision.</p>



<a name="213505129"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213505129" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213505129">(Oct 16 2020 at 00:32)</a>:</h4>
<p>I'm not really sure what else there is to discuss then--the only thing missing for that is compiler support for indicating whether to use scalar or vector implementations, I think?</p>



<a name="213505191"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213505191" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213505191">(Oct 16 2020 at 00:34)</a>:</h4>
<p>what else <strong>is</strong> there to discuss?</p>



<a name="213505263"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213505263" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213505263">(Oct 16 2020 at 00:34)</a>:</h4>
<p>isn't there no way of moving forward until we have compiler support?</p>



<a name="213505329"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213505329" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213505329">(Oct 16 2020 at 00:36)</a>:</h4>
<p>Sure, that's why I was trying to warm up to draft some compiler commits two hours ago, but the time seems to have flown since then.</p>



<a name="213505434"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213505434" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213505434">(Oct 16 2020 at 00:37)</a>:</h4>
<p>well, I thought that's what we were going to discuss before implementing it</p>



<a name="213505480"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213505480" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213505480">(Oct 16 2020 at 00:38)</a>:</h4>
<p>sorry, I didn't realize you were already doing that</p>



<a name="213505517"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213505517" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213505517">(Oct 16 2020 at 00:38)</a>:</h4>
<p>I got distracted before even really getting started, as usual.</p>



<a name="213505605"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213505605" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213505605">(Oct 16 2020 at 00:40)</a>:</h4>
<p>doesn't adding a new attribute with new semantics probably require an RFC?</p>



<a name="213505615"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213505615" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213505615">(Oct 16 2020 at 00:40)</a>:</h4>
<p>I'm not really sure where the threshold is but that seems past it</p>



<a name="213505879"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213505879" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213505879">(Oct 16 2020 at 00:44)</a>:</h4>
<p>No.<br>
There are already ways to describe unstable annotations where necessary for compiler usage.<br>
And the names really did mean about as much to me as #[foo] and #[bar].</p>



<a name="213506049"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213506049" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213506049">(Oct 16 2020 at 00:47)</a>:</h4>
<p>I wasn't concerned so much about the names as continuations</p>



<a name="213506117"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213506117" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213506117">(Oct 16 2020 at 00:48)</a>:</h4>
<p>That also was purely a thought regarding implementation details, and the internals of the compiler are not foreign to resumable or retryable logic.</p>



<a name="213506120"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213506120" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213506120">(Oct 16 2020 at 00:48)</a>:</h4>
<p>I'm sure the actual attributes will fall out of however the implementation works</p>



<a name="213506171"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213506171" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213506171">(Oct 16 2020 at 00:49)</a>:</h4>
<p>Right, my argument was just that it seems like an overcomplication</p>



<a name="213506243"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213506243" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213506243">(Oct 16 2020 at 00:50)</a>:</h4>
<p>I'm certain it could be done, I'm just not sure it should be</p>



<a name="213507625"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213507625" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213507625">(Oct 16 2020 at 01:17)</a>:</h4>
<p>So my experience is that it is... very painful to implement heavily cfg'd code because it is incredibly leaky. It is really not meant for selecting between logic paths on the sort of fine-grained level we would need here, because if a function block wants to vectorize, it really wants to go all in one step. If it hops back and forth between vector registers and other registers or the stack a lot, we introduce the potential to be slower than scalar. We don't want to fallback in a piecemeal fashion.</p>
<p>And currently the codegen logic for simd_* ops lives in rustc_codegen_llvm, and that is a MIR-&gt;LLVM step. Also, logic has been implemented in the (I presume similar) rustc_codegen_cranelift crate in anticipation of landing in order to handle this. So, we would want to be able to have a backend support whatever they can support or not if they don't.</p>
<p>So in order to lift the relevant aspects (to us) of SIMD codegen out of LLVM and compile nicely, we either have to devise a way to ask the backend to try twice on a given function block, with different arguments each time, or we have to just teach rustc about vectors and hope the backend makes the best of it.</p>



<a name="213509282"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213509282" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213509282">(Oct 16 2020 at 01:48)</a>:</h4>
<blockquote>
<p>So my experience is that it is... very painful to implement heavily cfg'd code because it is incredibly leaky. It is really not meant for selecting between logic paths on the sort of fine-grained level we would need here, because if a function block wants to vectorize, it really wants to go all in one step. If it hops back and forth between vector registers and other registers or the stack a lot, we introduce the potential to be slower than scalar. We don't want to fallback in a piecemeal fashion.</p>
</blockquote>
<p>Isn't this more of an argument for something cfg-like, then?  If there are only two options (scalar or vector) aren't we not looking for fine-grained control?  Also, I think that's very x86-centric, since other architectures can just as easily perform scalar and vector ops without changing registers</p>



<a name="213509655"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213509655" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213509655">(Oct 16 2020 at 01:56)</a>:</h4>
<p>I am not sure I understand what you are saying. ARMv8 zeros the other bits of a vector register like x86 does when a lower-bit value is written to it.</p>



<a name="213510178"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213510178" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213510178">(Oct 16 2020 at 02:06)</a>:</h4>
<p>Right, but those are the same registers and don't result in a pipeline stall or anything like that</p>



<a name="213511486"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213511486" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213511486">(Oct 16 2020 at 02:34)</a>:</h4>
<p>...so we let the selector do different things when it's targeting ARM, sure I guess?</p>



<a name="213511574"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213511574" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213511574">(Oct 16 2020 at 02:37)</a>:</h4>
<p>orrrr we can just add vectors to MIR I guess!</p>



<a name="213511636"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213511636" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213511636">(Oct 16 2020 at 02:39)</a>:</h4>
<p>are you suggesting that once you use a scalar implementation (like <code>Div</code> for integers on many architectures) the entire thing falls back to scalar?</p>



<a name="213511676"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213511676" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213511676">(Oct 16 2020 at 02:39)</a>:</h4>
<p>I'm not sure what the scope of this is</p>



<a name="213511809"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213511809" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213511809">(Oct 16 2020 at 02:42)</a>:</h4>
<p>I'm also not implying that you should have all of the answers, I just think it needs a broader discussion</p>



<a name="213511822"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213511822" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213511822">(Oct 16 2020 at 02:42)</a>:</h4>
<p>I don't know either now, and I don't feel like I have a clearer idea of anything.</p>



<a name="213511845"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213511845" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213511845">(Oct 16 2020 at 02:43)</a>:</h4>
<p>The difference with simd_div is that the implementation of it means LLVM knows (or claims to know) how to intelligently optimize it, it's not an actual statement about the relative speed.</p>



<a name="213512056"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213512056" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213512056">(Oct 16 2020 at 02:47)</a>:</h4>
<p>Yeah I agree with that to some extent.</p>



<a name="213512063"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213512063" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213512063">(Oct 16 2020 at 02:47)</a>:</h4>
<p>My proposal was for an abstracted selector function that can use an equally abstract comparator to attempt to use core::simd's contents so that work can continue inside stdsimd and that once the commits are done I can actually go back to not learning every grisly detail about how LLVM (or Cranelift, for that matter) works. If we introduce a bunch of cfgs, we have to cfg on <strong>all of them everywhere</strong> and now the details of backend codegen APIs are inside ours to an unnecessary degree.</p>



<a name="213512307"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213512307" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213512307">(Oct 16 2020 at 02:50)</a>:</h4>
<p>I suppose that's my point, if we're simply addressing backend inadequacy I feel like we can just select on whether or not SIMD is supported at all</p>



<a name="213512466"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213512466" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213512466">(Oct 16 2020 at 02:52)</a>:</h4>
<p>a binary yes/no means that every time a new intrinsic arrives, support has to also appear in every single codegen backend or else we don't use SIMD at all.</p>



<a name="213512553"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213512553" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213512553">(Oct 16 2020 at 02:53)</a>:</h4>
<p>do we expect that to be a common occurrence? I assume not</p>



<a name="213512590"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213512590" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213512590">(Oct 16 2020 at 02:54)</a>:</h4>
<p>also, from a practical sense, there's only one backend that supports SIMD at all, anyway</p>



<a name="213512690"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213512690" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213512690">(Oct 16 2020 at 02:55)</a>:</h4>
<p>I have "add simd_fneg" on my todo list still.</p>



<a name="213512700"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213512700" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213512700">(Oct 16 2020 at 02:55)</a>:</h4>
<p>there's lots of simd ops that aren't implemented in rustc's backends.</p>



<a name="213512811"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213512811" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213512811">(Oct 16 2020 at 02:56)</a>:</h4>
<p>there are definitely tons right now that aren't implemented, but I expect once stdsimd stabilizes there will be very few to add</p>



<a name="213512821"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213512821" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213512821">(Oct 16 2020 at 02:57)</a>:</h4>
<p>the entire AVX512 instruction set is about as old as Rust.</p>



<a name="213512855"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213512855" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213512855">(Oct 16 2020 at 02:57)</a>:</h4>
<p>that doesn't involve a new set of platform-intrinsics, though?</p>



<a name="213512858"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213512858" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213512858">(Oct 16 2020 at 02:57)</a>:</h4>
<p>does it?</p>



<a name="213512859"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213512859" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213512859">(Oct 16 2020 at 02:57)</a>:</h4>
<p>it should already support AVX512</p>



<a name="213512925"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213512925" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213512925">(Oct 16 2020 at 02:58)</a>:</h4>
<p>Every time they add a new concept, it will.</p>



<a name="213513023"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213513023" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213513023">(Oct 16 2020 at 02:59)</a>:</h4>
<p>only if that's something we decide to make portable</p>



<a name="213513095"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213513095" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213513095">(Oct 16 2020 at 03:00)</a>:</h4>
<p>or if LLVM does, for that matter</p>



<a name="213513098"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213513098" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213513098">(Oct 16 2020 at 03:00)</a>:</h4>
<p>If something arrives in core::arch it will lead to updates in the platform intrinsics.</p>



<a name="213513122"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213513122" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213513122">(Oct 16 2020 at 03:00)</a>:</h4>
<p>with some low probability, but with enough intrinsics added, low probability becomes a certainty.</p>



<a name="213513140"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213513140" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213513140">(Oct 16 2020 at 03:01)</a>:</h4>
<p>well in its current state core:;arch uses llvm intrinsics primarily</p>



<a name="213513150"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213513150" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213513150">(Oct 16 2020 at 03:01)</a>:</h4>
<p>Exactly.</p>



<a name="213513220"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213513220" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213513220">(Oct 16 2020 at 03:01)</a>:</h4>
<p>are you suggesting the entire breadth of all vendor intrinsics be converted to platform-intrinsics?</p>



<a name="213513272"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213513272" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213513272">(Oct 16 2020 at 03:02)</a>:</h4>
<p>I think that's significantly outside of the scope of this project group</p>



<a name="213513279"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213513279" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213513279">(Oct 16 2020 at 03:02)</a>:</h4>
<p>No, I am saying that probabilistically it will happen anyways.</p>



<a name="213513298"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213513298" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213513298">(Oct 16 2020 at 03:02)</a>:</h4>
<p>Yes, and there was an expressed desire to untether our API's backend from LLVM.</p>



<a name="213513354"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213513354" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213513354">(Oct 16 2020 at 03:03)</a>:</h4>
<p>I have no problem with extending platform intrinsics for stdsimd and not using any llvm, but I'm concerned about risking stabilization of std::simd for a huge feature that is primarily motivated by something else</p>



<a name="213513619"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213513619" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213513619">(Oct 16 2020 at 03:06)</a>:</h4>
<p>we may go another who knows how many years before anyone even attempts to make another backend that supports SIMD.  it could also be very soon but I think it should be addressed when that comes up</p>



<a name="213513749"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213513749" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213513749">(Oct 16 2020 at 03:08)</a>:</h4>
<p>I think it's completely possible it _never_ happens</p>



<a name="213513916"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213513916" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213513916">(Oct 16 2020 at 03:11)</a>:</h4>
<p>"huge feature"?</p>



<a name="213514041"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213514041" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213514041">(Oct 16 2020 at 03:14)</a>:</h4>
<p>if it's bleeding into caller functions that seems like a big deal to me</p>



<a name="213514118"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213514118" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213514118">(Oct 16 2020 at 03:15)</a>:</h4>
<p>#[cfg] does bleed a lot, yes.</p>



<a name="213514199"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213514199" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213514199">(Oct 16 2020 at 03:16)</a>:</h4>
<div class="codehilite"><pre><span></span><code>fn foo(x: f32x4, y: f32x4) -&gt; i32x4 {
    (x + y).round_to_int()
}
</code></pre></div>


<p>if <code>round_to_int</code> only has a scalar function, what happens to the add?</p>



<a name="213514238"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213514238" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213514238">(Oct 16 2020 at 03:17)</a>:</h4>
<p>That is literally already a concern with target feature.</p>



<a name="213514327"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213514327" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213514327">(Oct 16 2020 at 03:18)</a>:</h4>
<p>With target-feature they explicitly don't bleed into the caller, and the functions don't inline</p>



<a name="213514345"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213514345" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213514345">(Oct 16 2020 at 03:19)</a>:</h4>
<p>Well yes, and that's a problem because it's sloooow.</p>



<a name="213514353"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213514353" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213514353">(Oct 16 2020 at 03:19)</a>:</h4>
<p>I would also consider target-feature to be a huge feature</p>



<a name="213514377"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213514377" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213514377">(Oct 16 2020 at 03:19)</a>:</h4>
<p>I agree it's a problem but the solution was generally "wait for an effects system", as far as I know</p>



<a name="213514472"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213514472" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213514472">(Oct 16 2020 at 03:21)</a>:</h4>
<p>target-feature 1.1 has already been proposed (and still unstable) for longer than the entire proposed duration of this project group</p>



<a name="213514721"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213514721" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213514721">(Oct 16 2020 at 03:26)</a>:</h4>
<p>Well yes. <a href="https://doc.rust-lang.org/unstable-book/language-features/repr-simd.html">https://doc.rust-lang.org/unstable-book/language-features/repr-simd.html</a></p>



<a name="213514749"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213514749" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213514749">(Oct 16 2020 at 03:27)</a>:</h4>
<p>There's quite a lot of these. <a href="https://github.com/rust-lang/rust/issues/39954">https://github.com/rust-lang/rust/issues/39954</a></p>



<a name="213529550"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213529550" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213529550">(Oct 16 2020 at 08:05)</a>:</h4>
<p>Another disadvantage of <code>#[cfg(codegen_backend)]</code> is that it prevents mixing a libstd compiled with one backend with user code compiled with another backend even when they are ABI compatible. (I plan to mix cg_clif with a cg_llvm sysroot in the future. And a game may want to compile the engine with cg_llvm in release mode for performance and the game code with cg_clif for fast iteration times.)</p>



<a name="213557441"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213557441" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213557441">(Oct 16 2020 at 13:10)</a>:</h4>
<p>I'm not sure that's true, but if it is it can still use a new attribute with similar semantics but allows for that possibility. I'm not opposed to adding some new attribute, I'm mostly opposed to the magic of continuations which makes it very unclear how any particular function actually lowers, and opposed to doing so much work for supporting multiple SIMD backends when there is no immediate plan for any</p>



<a name="213557535"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213557535" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213557535">(Oct 16 2020 at 13:11)</a>:</h4>
<p>If something like function multiversioning is outside of the scope of this project group, I think supporting multiple SIMD backends is definitely outside the scope.  But I think I've made my position clear at this point haha.</p>



<a name="213591914"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213591914" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213591914">(Oct 16 2020 at 17:45)</a>:</h4>
<p>I feel like this needs a mechanism similar to the way the link attribute can specify a cfg that gets evaluated in the final crate that links the library, to determine if it applies.</p>



<a name="213592044"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213592044" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213592044">(Oct 16 2020 at 17:46)</a>:</h4>
<p>Something that allows selecting from a set of these functions in std/core at compile time of the user's code, not just when std/core is compiled.</p>



<a name="213592067"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213592067" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213592067">(Oct 16 2020 at 17:46)</a>:</h4>
<p>(That's leaving aside runtime detection.)</p>



<a name="213592145"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213592145" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213592145">(Oct 16 2020 at 17:47)</a>:</h4>
<p>I do very much think that we need to be able to add new operations on a regular basis without having to touch every architecture.</p>



<a name="213592195"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213592195" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213592195">(Oct 16 2020 at 17:47)</a>:</h4>
<p>And the architectures we don't touch should automatically use the portable pure-Rust implementations.</p>



<a name="213592365"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213592365" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213592365">(Oct 16 2020 at 17:49)</a>:</h4>
<p>One version of this could be to lower it in MIR where a target needs to opt-out of that once it supports the intrinsic.</p>



<a name="213592590"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213592590" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213592590">(Oct 16 2020 at 17:51)</a>:</h4>
<p><span class="user-mention" data-user-id="125270">@scottmcm</span> I think that's my preferred mechanism.  The intrinsics are always available, but rustc may or may not lower them to pure rust depending on backend?</p>



<a name="213593054"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213593054" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213593054">(Oct 16 2020 at 17:54)</a>:</h4>
<p><span class="user-mention" data-user-id="239881">@Josh Triplett</span> if the functions are marked inline and the selection is done while lowering is that a sufficient guarantee that it occurs in user code?</p>



<a name="213593287"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213593287" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213593287">(Oct 16 2020 at 17:56)</a>:</h4>
<p>I don't know if inlineable functions are sufficient for efficient SIMD code in the accelerated case. That would probably suffice for the unaccelerated portable implementation though.</p>



<a name="213593424"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213593424" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213593424">(Oct 16 2020 at 17:57)</a>:</h4>
<p>But yeah, having these be handled via lowering that a target can then override with its own lowering makes sense to me.</p>



<a name="213594796"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213594796" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213594796">(Oct 16 2020 at 18:06)</a>:</h4>
<p>This is one of those places where it'd be really nice to have a data-driven way to do the lowering, since writing out the code manually for MIR lowering of all the different things would be a royal pain.  Unless maybe it turned into a <code>compiler-builtins</code> call?  So we do a good job of not linking the universe when things from there are unused?</p>



<a name="213599022"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213599022" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213599022">(Oct 16 2020 at 18:44)</a>:</h4>
<p>Teaching rustc about vectors it is, then.</p>



<a name="213599118"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213599118" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213599118">(Oct 16 2020 at 18:44)</a>:</h4>
<p>I actually think all of the metadata is there from repr(simd) at least</p>



<a name="213599624"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213599624" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213599624">(Oct 16 2020 at 18:49)</a>:</h4>
<p><span class="user-mention silent" data-user-id="312331">Caleb Zulawski</span> <a href="#narrow/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation/near/213557535">said</a>:</p>
<blockquote>
<p>If something like function multiversioning is outside of the scope of this project group, I think supporting multiple SIMD backends is definitely outside the scope.  But I think I've made my position clear at this point haha.</p>
</blockquote>
<p>At this point it's a matter of removing the practical blockers to delivering our API, so we can get back to writing our API. If implementing function multiversioning is what's required to do that, then so be it. This is why I suggested removing <strong>all</strong> vector widths except 1 or 2.</p>



<a name="213600733"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213600733" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213600733">(Oct 16 2020 at 18:58)</a>:</h4>
<p>Because we <em>will</em> need every single ounce of bandwidth we have to plow through all the reasons that no one has resolved this issue before.</p>



<a name="213601370"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213601370" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213601370">(Oct 16 2020 at 19:04)</a>:</h4>
<p>I agree we need to solve it, I was concerned about moving forward with something like continuations, which I had technical concerns with, without even having a discussion on the implementation</p>



<a name="213601526"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213601526" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213601526">(Oct 16 2020 at 19:06)</a>:</h4>
<p>I'm mostly indifferent to the collectively agreed upon solution, I just want to make sure this discussion occurs</p>



<a name="213604455"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213604455" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213604455">(Oct 16 2020 at 19:33)</a>:</h4>
<p>I appreciate that you want to have a discussion, which is why I attempted to enumerate the alternatives, which included teaching rustc about vectors.</p>
<p>I feel like I made a mistake by saying "continuation", because really, what my idea was <strong>about</strong> was an abstraction fence that would isolate us from both the detalis of how our implementation is selected and also isolate us from the details of the final codegen backend, while still being able to express as many things a possible inside stdsimd, not have to go to the compiler, and not have to have details of codegen backends live in our API. You raised a concern which was soluble via a mechanism to retry, so I tossed out the first thing that came to mind for doing so.</p>
<p>Now, embedding vectors in the MIR satisfies me in some ways, because I believe in vectors as a basic computational concept and so I think they should have first-class representation in any serious language. However, people have expressed that making compiler commits can be daunting, and I agree, which is why we split out into a separate repo in the first place. I feel like having scalar lowerings live entirely inside rustc IS in fact a fine design, but will effectively "split the party" and require us to keep going to the compiler to adjust our API.</p>



<a name="213604803"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213604803" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213604803">(Oct 16 2020 at 19:36)</a>:</h4>
<p>Which is why I expressed frustration a few times... I feel like I was already having to argue against my <strong>personal</strong> preference!</p>



<a name="213604886"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213604886" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213604886">(Oct 16 2020 at 19:37)</a>:</h4>
<p>I'm ok with expanding compiler functionality as long as in the meantime we can continue with LLVM intrinsics.  I think if the selection done entirely within the compiler (which seems to me most philosophically correct) that also means anything we write with LLVM intrinsics should have a fairly trivial conversion to platform intrinsics</p>



<a name="213604999"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213604999" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213604999">(Oct 16 2020 at 19:38)</a>:</h4>
<p>Though I'm ok with any solution that doesn't end up blocking library API development, really</p>



<a name="213624998"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213624998" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213624998">(Oct 16 2020 at 23:44)</a>:</h4>
<p>This is a very long thread and so I'm not sure I've absorbed every nuance in catching up, but just to respond to some of the very recent potints:</p>
<ul>
<li>Having vector support happen within MIR <strong>sounds like</strong> the best long term solution (but all I really know about MIR is "it's a layer that exists").</li>
<li>If vectors are in MIR, then MIRI can "automatically" support simd-using code, and it's generally much better for miri to be able to cover as much code as possible.</li>
<li>The MIR can probably (?) lower to the appropriate codegen system (llvm, cranelift, whatever) through the normal well established channels.</li>
<li>The public API then targets rustc intrinsics -&gt; becomes MIR -&gt; becomes codegen IR -&gt; becomes assembly</li>
<li>It sounds like new functions will always <em>default</em> to fallback mode and then specific situations can opt-in to having a better version. This would be like trait specialization, but for assembly.</li>
</ul>



<a name="213625714"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Portable%20pure-Rust%20implementation/near/213625714" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Portable.20pure-Rust.20implementation.html#213625714">(Oct 17 2020 at 00:00)</a>:</h4>
<p>Oh, MIRI is a great point.  Hopefully it can get the MIR of compiler-builtins implementations, so they can be written in rust instead of directly in MIR?</p>
<blockquote>
<p>Though I'm ok with any solution that doesn't end up blocking library API development, really</p>
</blockquote>
<p>Arguably most (all?) of the API can be defined even if the optimized implementations can't be checked in immediately.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>